package com.woniuxy.tfss.web.admin;

import com.woniuxy.tfss.entity.Category;
import com.woniuxy.tfss.entity.ResponseEntity;
import com.woniuxy.tfss.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller("adminCategoryController")
@RequestMapping("admin/category")
@CrossOrigin
@Slf4j
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 查询所有种类
     * @return
     */
    @GetMapping("list")
    @ResponseBody
    public ResponseEntity<List<Category>> list(){
        List<Category> categories=categoryService.list();
        return new ResponseEntity<>(categories);
    }
}
